home *** CD-ROM | disk | FTP | other *** search
/ PCMania 64 / PCMania CD64_1.iso / phy / phy001 / graph / graph20.arj / LIB / CFAR / GRFLIB.H < prev   
Encoding:
C/C++ Source or Header  |  1996-11-30  |  29.6 KB  |  1,244 lines

  1. //   Fichero de inclusión para compatibilizar la libreria GRAPH
  2. //  con Turbo C (no sería difícil adaptarla para otros compiladores)
  3. //      Por   N A V I   D.j.
  4.  
  5. #include <dos.h>
  6. #include <alloc.h>
  7.  
  8. typedef unsigned char  byte;
  9. typedef unsigned int   word;
  10. typedef unsigned long dword;
  11.  
  12. word Ssegmento;
  13. word Soffset;
  14.  word dvuelta;
  15.  word wvuelta;
  16.  byte bvuelta;
  17.  
  18. extern void *DBORRAPANTALLA;
  19. extern void *DPONPIXEL;
  20. extern void *DCOGEPIXEL;
  21. extern void *DLINEA;
  22. extern void *DCREAVIRTUAL;
  23. extern void *DDESTVIRTUAL;
  24. extern void *DCOPIAPANTALLA;
  25. extern void *DTRATAERROR;
  26. extern void *DCARGASPRITE;
  27. extern void *DDIBUJASPRITE;
  28. extern void *DDESTSPRITE;
  29. extern void *DVACIAMEM;
  30. extern void *DFDIBUJASPRITE;
  31. extern void *DFLINEA;
  32. extern void *DFPONPIXEL;
  33. extern void *DFCOGEPIXEL;
  34. extern void *DFBORRAPANTALLA;
  35. extern void *DCOGECOLOR;
  36. extern void *DPONCOLOR;
  37. extern void *DCOGEPALETA;
  38. extern void *DPONPALETA;
  39. extern void *DFADEDOWN;
  40. extern void *DCARGAPALETA;
  41. extern void *DFADEUP;
  42. extern void *DFADETO;
  43. extern void *DBLACKOUT;
  44. extern void *DCARGACEL;
  45. extern void *DCARGAANIMA;
  46. extern void *DPONFRAMEANIMA;
  47. extern void *DFPONFRAMEANIMA;
  48. extern void *DDESTANIMA;
  49. extern void *DINSERTADIRSPRITE;
  50. extern void *DINSERTADIRANIMA;
  51. extern void *DSEGMENTOSPRITE;
  52. extern void *DSEGMENTOANIMA;
  53. extern void *DSEGMENTOPAL;
  54. extern void *DSEGMENTOPV;
  55. extern void *DINSERTADIRPV;
  56. extern void *DINSERTADIRPAL;
  57. extern void *DDESCOMPPUNTOS;
  58. extern void *DDESCOMPWORM;
  59. extern void *DFCAJA;
  60. extern void *DCAJA;
  61. extern void *DFRECTANGULO;
  62. extern void *DRECTANGULO;
  63. extern void *DPOLIGONO;
  64. extern void *DFPOLIGONO;
  65. extern void *DCREASPRITE;
  66. extern void *DCAMBIASPRITES;
  67. extern void *DGETIMAGEN;
  68. extern void *DFGETIMAGEN;
  69. extern void *DCIRCULO;
  70. extern void *DFCIRCULO;
  71. extern void *DLEEPCX;
  72. extern void *DDESTPALETA;
  73. extern void *DLEEBMP;
  74. extern void *DPLAYFLI;
  75. extern void *DINICGRAPH;
  76. extern void *DENDGRAPH;
  77. extern void *DCARGAFUENTE;
  78. extern void *DCAMBIATIPO;
  79. extern void *DQUETIPO;
  80. extern void *DESCLETRA;
  81. extern void *DCOGEFUENTEDOS;
  82. extern void *DSETCURSOR;
  83. extern void *DGETCURSOR;
  84. extern void *DESCRIBE;
  85. extern void *DLEELETRA;
  86. extern void *DLEELETRAECHO;
  87. extern void *DLEEBYTE;
  88. extern void *DLEECADENA;
  89. extern void *DLEEWORD;
  90. extern void *DESCBYTE;
  91. extern void *DESCWORD;
  92. extern void *DWRITE;
  93. extern void *DNUEVOARCHIVO;
  94. extern void *DLEEENTRADA;
  95. extern void *DLEETROZO;
  96. extern void *DLONGITUDFILE;
  97. extern void *DFLIPCOPY;
  98. extern void *DFLIP;
  99. extern void *DSEGMENTOFUENTE;
  100. extern void *DSETSTART;
  101. extern void *DDOBLALINEAS;
  102. extern void *DSETVSPIXELS;
  103. extern void *DPIDEXMS;
  104. extern void *DLIBERAXMS;
  105. extern void *DGETADDRESS;
  106. extern void *DMAXIMAXMS;
  107. extern void *DGUARDAFLAT;
  108. extern void *DCARGAFLAT;
  109. extern void *DCARGABLOQUE;
  110. extern void *DCARGAMAPA;
  111. extern void *DDESTBLOQUE;
  112. extern void *DDESTMAPA;
  113. extern void *DDIBUJAMAPA;
  114. extern void *DPOSMAPA;
  115. extern void *DINSERTADIRBLOQUE;
  116. extern void *DINSERTADIRMAPA;
  117. extern void *DSEGMENTOBLOQUE;
  118. extern void *DSEGMENTOMAPA;
  119. extern void *DRESETGRAPH;
  120. extern void *DMODOGRAFICO;
  121. extern void *DMODOTEXTO;
  122. extern void *DCREAMAPA;
  123. extern void *DCREABLOQUE;
  124. extern void *DDESTFUENTE;
  125. extern void *DINSERTADIRFUENTE;
  126.  
  127. extern word LERROR;                     //  La variable de errores.
  128. extern word REGISTRO;                   //  El nº de campo total.
  129.  
  130. word PideMEM(word canti)                //  Pide "canti" párrafos de memoria.
  131. {
  132.  word p;
  133.  int stat;
  134.  
  135.  asm push es;
  136.  asm push ds;
  137.  stat=allocmem(canti, &p);
  138.  asm pop ds;
  139.  asm pop es;
  140.  
  141.  return p;
  142.  }
  143.  
  144. void LiberaMEM(word puntero)        //  Libera un bloque de memoria.
  145. {
  146.  freemem(puntero);
  147.  }
  148.  
  149. void WaitVR(void)                       //  Espera el retrazo vertical.
  150.  {
  151.    asm  .386
  152.    asm  MOV   DX,03DAh;
  153.  St1:
  154.    asm  IN    AL,DX;
  155.    asm  TEST  AL,08h;
  156.    asm  JZ    St1;
  157.  St2:
  158.    asm  IN    AL,DX;
  159.    asm  TEST  AL,08h;
  160.    asm  JNZ   St2;
  161.    }
  162.  
  163. byte CargaAnima(char *nombre,word longX,word longY,word NSprites){
  164.     Ssegmento=FP_SEG(nombre);
  165.     Soffset=FP_OFF(nombre);
  166.         asm  push es;
  167.         asm  pusha;
  168.     asm  push ds;
  169.     asm  mov ax,Ssegmento;
  170.     asm  mov ds,ax;
  171.     asm  mov dx,Soffset;
  172.     asm  mov ax, NSprites;
  173.     asm  mov bx, longX;
  174.     asm  mov cx, longY;
  175.         asm  call dword ptr DCARGAANIMA;
  176.     asm  pop ds;
  177.         asm  mov bvuelta,al;
  178.         asm  popa;
  179.         asm  pop es;
  180.         return bvuelta;}
  181.  
  182. void PonFrameAnima(byte hdl,byte pv,word x,word y,word frame){
  183.         asm  push es;
  184.         asm  push ds;
  185.         asm  pusha;
  186.     asm  mov al,pv;
  187.     asm  mov ah,hdl
  188.     asm  mov bx,y;
  189.     asm  mov cx,frame;
  190.     asm  mov bp,x;
  191.         asm  call dword ptr DPONFRAMEANIMA;
  192.         asm  popa;
  193.         asm  pop ds;
  194.         asm  pop es;}
  195.  
  196. void fPonFrameAnima(byte hdl,byte pv,word x,word y,word frame){
  197.         asm  push es;
  198.         asm  push ds;
  199.         asm  pusha;
  200.     asm  mov al,pv;
  201.     asm  mov ah,hdl
  202.     asm  mov bx,y;
  203.     asm  mov cx,frame;
  204.     asm  mov bp,x;
  205.         asm  call dword ptr DFPONFRAMEANIMA;
  206.         asm  popa;
  207.         asm  pop ds;
  208.         asm  pop es;}
  209.  
  210. void DestAnima(byte hdl){
  211.         asm  push es;
  212.         asm  pusha;
  213.     asm  mov al,hdl;
  214.         asm  call dword ptr DDESTANIMA;
  215.         asm  popa;
  216.         asm  pop es;}
  217. /*
  218. void CogeColor(byte registro, byte &crojo, byte &cverde, byte &cazul) {
  219.         asm  al, registro;
  220.         asm  call dword ptr DCOGECOLOR;
  221.         asm  crojo, cl;
  222.         asm  cverde, bl;
  223.         asm  cazul, al;}
  224. */
  225. void PonColor(byte NReg,byte R,byte G,byte B){
  226.     asm  mov cl,R;
  227.     asm  mov bl,G;
  228.     asm  mov al,B;
  229.     asm  mov ah,NReg;
  230.         asm  call dword ptr DPONCOLOR;}
  231.  
  232. byte CogePaleta(void) {
  233.         asm  push es;
  234.         asm  pusha;
  235.         asm  call dword ptr DCOGEPALETA;
  236.         asm  popa
  237.         asm  pop es
  238.     asm  mov bvuelta,al;
  239.     return bvuelta;}
  240.  
  241. void PonPaleta(byte Hdl,byte FCol,byte LCol){
  242.         asm  push es
  243.         asm  pusha
  244.     asm  mov bl,LCol;
  245.     asm  mov al,FCol;
  246.     asm  mov ah,Hdl;
  247.         asm  call dword ptr DPONPALETA;
  248.         asm  popa;
  249.         asm  pop es;}
  250.  
  251. byte CargaPaleta(char *nombre){
  252.     Ssegmento=FP_SEG(nombre);
  253.     Soffset=FP_OFF(nombre);
  254.         asm  push es;
  255.     asm  push ds;
  256.     asm  mov ax,Ssegmento;
  257.     asm  mov ds,ax;
  258.     asm  mov dx,Soffset;
  259.         asm  call dword ptr DCARGAPALETA;
  260.     asm  pop ds;
  261.         asm  mov bvuelta,al
  262.         asm  pop es;
  263.         return bvuelta;}
  264.  
  265. void FadeDown(word Retar,byte FCol,byte LCol){
  266.         asm  pusha;
  267.     asm  mov dh,LCol;
  268.     asm  mov dl,FCol;
  269.     asm  mov cx,Retar;
  270.         asm  call dword ptr DFADEDOWN;
  271.         asm  popa;}
  272.  
  273. void FadeUp(word Retar,byte FCol,byte LCol){
  274.         asm  pusha;
  275.     asm  mov dh,LCol;
  276.     asm  mov dl,FCol;
  277.     asm  mov cx,Retar;
  278.         asm  call dword ptr DFADEUP;
  279.         asm  popa;}
  280.  
  281. void FadeTo(byte Hdl,word Retar,byte FCol,byte LCol){
  282.         asm  push es;
  283.         asm  pusha;
  284.     asm  mov dh,LCol;
  285.     asm  mov dl,FCol;
  286.     asm  mov cx,Retar;
  287.     asm  mov al,Hdl;
  288.         asm  call dword ptr DFADETO;
  289.         asm  popa;
  290.         asm  pop es;}
  291.  
  292. void BlackOut(byte FCol,byte LCol){
  293.     asm  mov bl,LCol;
  294.     asm  mov al,FCol;
  295.         asm  call dword ptr DBLACKOUT;}
  296.  
  297. void DestPaleta(byte hdl){
  298.         asm  push es;
  299.     asm  mov al,hdl;
  300.         asm  call dword ptr DDESTPALETA;
  301.         asm  pop es;}
  302.  
  303. void PonPixel(word x,word y,byte color,byte pv){
  304.         asm  push es;
  305.         asm  pusha
  306.         asm  mov bx,x;
  307.     asm  mov dx,y;
  308.     asm  mov cl,color;
  309.     asm  mov al,pv;
  310.         asm  call dword ptr DPONPIXEL;
  311.         asm  popa
  312.         asm  pop es;}
  313.  
  314. void fPonPixel(word x,word y,byte color,byte pv){
  315.         asm  push es;
  316.         asm  pusha
  317.         asm  mov bx,x;
  318.     asm  mov dx,y;
  319.     asm  mov cl,color;
  320.     asm  mov al,pv;
  321.         asm  call dword ptr DFPONPIXEL;
  322.         asm  popa
  323.         asm  pop es;}
  324.  
  325. void BorraPantalla(byte color,byte pv){
  326.         asm  push es;
  327.         asm  pushad
  328.         asm  mov cl,color;
  329.     asm  mov al,pv;
  330.         asm  call dword ptr DBORRAPANTALLA;
  331.         asm  popad
  332.         asm  pop es;}
  333.  
  334. void fBorraPantalla(byte color,byte pv){
  335.         asm  push es;
  336.         asm  pushad
  337.         asm  mov cl,color;
  338.     asm  mov al,pv;
  339.         asm  call dword ptr DFBORRAPANTALLA;
  340.         asm  popad
  341.         asm  pop es;}
  342.  
  343. byte CogePixel(word x,word y,byte pv){
  344.         asm  push es;
  345.         asm  pusha
  346.     asm  mov al,pv;
  347.     asm  mov bx,x;
  348.     asm  mov dx,y;
  349.         asm  call dword ptr DCOGEPIXEL;
  350.     asm  mov bvuelta,cl;
  351.         asm  popa
  352.         asm  pop es;
  353.     return bvuelta;}
  354.  
  355. byte fCogePixel(word x,word y,byte pv){
  356.         asm  push es;
  357.         asm  pusha
  358.     asm  mov al,pv;
  359.     asm  mov bx,x;
  360.     asm  mov dx,y;
  361.         asm  call dword ptr DFCOGEPIXEL;
  362.     asm  mov bvuelta,cl;
  363.         asm  popa
  364.         asm  pop es;
  365.     return bvuelta;}
  366.  
  367. void Rectangulo(word x1,word y1,word x2,word y2,byte col,byte hdl){
  368.         asm  pusha;
  369.     asm  mov al,hdl;
  370.     asm  mov cl,col;
  371.     asm  mov bx,x1;
  372.     asm  mov si,y1;
  373.     asm  mov dx,x2;
  374.     asm  mov di,y2;
  375.         asm  call dword ptr DRECTANGULO;
  376.         asm  popa;}
  377.  
  378. void fRectangulo(word x1,word y1,word x2,word y2,byte col,byte hdl){
  379.         asm  pusha;
  380.     asm  mov al, hdl;
  381.     asm  mov cl, col;
  382.     asm  mov bx,x1;
  383.     asm  mov si,y1;
  384.     asm  mov dx,x2;
  385.     asm  mov di,y2;
  386.         asm  call dword ptr DFRECTANGULO;
  387.         asm  popa;}
  388.  
  389. void Circulo(word Xcen,word Ycen,word radio,byte hdl,byte col){
  390.         asm  pusha;
  391.         asm  mov ch,hdl;
  392.     asm  mov bx,Xcen;
  393.     asm  mov dx,Ycen;
  394.     asm  mov ax,radio;
  395.     asm  mov cl,col;
  396.         asm  call dword ptr DCIRCULO;
  397.         asm  popa;}
  398.  
  399. void fCirculo(word Xcen,word Ycen,word radio,byte hdl,byte col){
  400.         asm  pusha;
  401.     asm  mov ch,hdl;
  402.     asm  mov bx,Xcen;
  403.     asm  mov dx,Ycen;
  404.     asm  mov ax,radio;
  405.     asm  mov cl,col;
  406.         asm  call dword ptr DFCIRCULO;
  407.         asm  popa;}
  408.  
  409. void ModoGrafico(void){
  410.         asm  push es;
  411.         asm  push ds;
  412.         asm  pushad
  413.         asm  call dword ptr DMODOGRAFICO;
  414.         asm  popad
  415.         asm  pop ds;
  416.         asm  pop es;}
  417.  
  418. void ModoTexto(void){
  419.         asm  push es;
  420.         asm  push ds;
  421.         asm  pushad
  422.         asm  call dword ptr DMODOTEXTO;
  423.         asm  popad
  424.         asm  pop ds;
  425.         asm  pop es;}
  426.  
  427. void Linea(word Xi,word Yi,word Xf,word Yf,byte color,byte pv){
  428.         asm  pusha;
  429.         asm  push es;
  430.     asm  mov bx,Xi;
  431.     asm  mov dx,Xf;
  432.     asm  mov si,Yi;
  433.     asm  mov di,Yf;
  434.     asm  mov ch,color;
  435.     asm  mov al,pv;
  436.         asm  call dword ptr DLINEA;
  437.         asm  pop es;
  438.         asm  popa;}
  439.  
  440. void fLinea(word Xi,word Yi,word Xf,word Yf,byte color,byte pv){
  441.         asm  pusha;
  442.         asm  push es;
  443.     asm  mov bx,Xi;
  444.     asm  mov dx,Xf;
  445.     asm  mov si,Yi;
  446.     asm  mov di,Yf;
  447.     asm  mov ch,color;
  448.     asm  mov al,pv;
  449.         asm  call dword ptr DFLINEA;
  450.         asm  pop es;
  451.         asm  popa;}
  452.  
  453. void Caja(word x1,word y1,word x2,word y2,byte col,byte hdl){
  454.         asm  pusha;
  455.         asm  push es;
  456.     asm  mov al,hdl;
  457.     asm  mov cl,col;
  458.     asm  mov bx,x1;
  459.     asm  mov si,y1;
  460.     asm  mov dx,x2;
  461.     asm  mov di,y2;
  462.         asm  call dword ptr DCAJA;
  463.         asm  pop es;
  464.         asm  popa;}
  465.  
  466. void fCaja(word x1,word y1,word x2,word y2,byte col,byte hdl){
  467.         asm  pusha;
  468.         asm  push es;
  469.     asm  mov al,hdl;
  470.     asm  mov cl,col;
  471.     asm  mov bx,x1;
  472.     asm  mov si,y1;
  473.     asm  mov dx,x2;
  474.     asm  mov di,y2;
  475.         asm  call dword ptr DFCAJA;
  476.         asm  pop es;
  477.         asm  popa;}
  478.  
  479. // Para definir los vertices de un poligono hacerlo así:
  480. //  CHAR *Vertices = {32, 54, 132, 54}
  481.  
  482. void Poligono(char *PTRVertices,byte NVertices,byte col,byte hdl){
  483.     Ssegmento=FP_SEG(PTRVertices);
  484.     Soffset=FP_OFF(PTRVertices);
  485.     asm  push ds;
  486.         asm  pusha
  487.     asm  mov ax,Ssegmento;
  488.     asm  mov ds,ax;
  489.     asm  mov dx,Soffset;
  490.     asm  mov cl,col;
  491.     asm  mov al,hdl;
  492.     asm  mov ch,NVertices;
  493.         asm  call dword ptr DPOLIGONO;
  494.         asm  popa
  495.     asm  pop ds;}
  496.  
  497. void fPoligono(char *PTRVertices,byte NVertices,byte col,byte hdl){
  498.     Ssegmento=FP_SEG(PTRVertices);
  499.     Soffset=FP_OFF(PTRVertices);
  500.     asm  push ds;
  501.         asm  pusha
  502.     asm  mov ax,Ssegmento;
  503.     asm  mov ds,ax;
  504.     asm  mov dx,Soffset;
  505.     asm  mov cl,col;
  506.     asm  mov al,hdl;
  507.     asm  mov ch,NVertices;
  508.         asm  call dword ptr DFPOLIGONO;
  509.         asm  popa
  510.     asm  pop ds;}
  511.  
  512. byte CreaVirtual(void) {
  513.         asm  call dword ptr DCREAVIRTUAL;
  514.     asm  mov bvuelta,al;
  515.     return bvuelta;}
  516.  
  517. void CopiaPantalla(byte Opv,byte Dpv){
  518.         asm  push es;
  519.         asm  push ds;
  520.         asm  pusha
  521.         asm  mov al,Opv;
  522.     asm  mov ah,Dpv;
  523.         asm  call dword ptr DCOPIAPANTALLA;
  524.         asm  popa
  525.         asm  pop ds;
  526.         asm  pop es;}
  527.  
  528. void DestVirtual(byte pv){
  529.         asm  push es;
  530.         asm  pusha
  531.         asm  mov al,pv;
  532.         asm  call dword ptr DDESTVIRTUAL;
  533.         asm  popa
  534.         asm  pop es;}
  535.  
  536. word SegmentoPV(byte pv){
  537.     asm  push es;
  538.     asm  mov al,pv;
  539.         asm  call dword ptr DSEGMENTOPV;
  540.     asm  mov wvuelta,es;
  541.     asm  pop es;
  542.     return wvuelta;}
  543.  
  544. word SegmentoPal(byte Hdl){
  545.     asm  push es;
  546.     asm  mov al,Hdl;
  547.         asm  call dword ptr DSEGMENTOPAL;
  548.     asm  mov wvuelta,es;
  549.     asm  pop es;
  550.     return wvuelta;}
  551.  
  552. word SegmentoSprite(byte Hdl){
  553.     asm  push es;
  554.     asm  mov al,Hdl;
  555.         asm  call dword ptr DSEGMENTOSPRITE;
  556.     asm  mov wvuelta,es;
  557.     asm  pop es;
  558.     return wvuelta;}
  559.  
  560. word SegmentoAnima(byte Hdl){
  561.     asm  push es;
  562.     asm  mov al,Hdl;
  563.         asm  call dword ptr DSEGMENTOANIMA;
  564.     asm  mov wvuelta,es;
  565.     asm  pop es; 
  566.     return wvuelta;}
  567.  
  568. void VaciaMEM(void) { asm  call dword ptr DVACIAMEM; }
  569.  
  570. void TrataError(void) { asm  call dword ptr DTRATAERROR; }
  571.  
  572. byte InsertaDirPV(word seg){
  573.     asm  push es;
  574.     asm  mov ax,seg;
  575.     asm  mov es,ax;
  576.         asm  call dword ptr DINSERTADIRPV;
  577.     asm  mov bvuelta,al;
  578.     asm  pop es;
  579.     return bvuelta;}
  580.  
  581. void InsertaDirPal(word seg){
  582.     asm  push es;
  583.     asm  mov ax,seg;
  584.     asm  mov es,ax;
  585.         asm  call dword ptr DINSERTADIRPAL;
  586.     asm  pop es;}
  587.  
  588. void InsertaDirSprite(word seg, word lx, word ly){
  589.     asm  push es;
  590.     asm  mov ax,seg;
  591.     asm  mov es,ax;
  592.         asm  mov ax,lx;
  593.         asm  mov cx,ly;
  594.         asm  call dword ptr DINSERTADIRSPRITE;
  595.     asm  pop es;}
  596.  
  597. void InsertaDirAnima(word seg, word lx, word ly, word num){
  598.     asm  push es;
  599.     asm  mov ax,seg;
  600.     asm  mov es,ax;
  601.         asm  mov ax,lx;
  602.         asm  mov cx,ly;
  603.         asm  mov si,num;
  604.         asm  call dword ptr DINSERTADIRANIMA;
  605.     asm  pop es;}
  606.  
  607. byte CargaSprite(char *nombre,word lonx,word lony){
  608.     Ssegmento=FP_SEG(nombre);
  609.     Soffset=FP_OFF(nombre);
  610.         asm  pusha;
  611.         asm  push es;
  612.     asm  push ds;
  613.     asm  mov ax,Ssegmento;
  614.     asm  mov ds,ax;
  615.     asm  mov dx,Soffset;
  616.     asm  mov bx,lonx;
  617.     asm  mov cx,lony;
  618.         asm  call dword ptr DCARGASPRITE;
  619.     asm  pop ds;
  620.         asm  mov bvuelta,al;
  621.         asm  pop es;
  622.         asm  popa;
  623.         return bvuelta;}
  624.  
  625. void DestSprite(byte hdl){
  626.         asm  push es;
  627.         asm  pusha
  628.     asm  mov al,hdl;
  629.         asm  call dword ptr DDESTSPRITE;
  630.         asm  popa
  631.         asm  pop es;}
  632.  
  633. void CambiaSprites(byte hdl1,byte hdl2){
  634.         asm  pusha;
  635.     asm  mov al,hdl1;
  636.     asm  mov dl,hdl2;
  637.         asm  call dword ptr DCAMBIASPRITES;
  638.         asm  popa;}
  639.  
  640. byte CreaSprite(word lx,word ly){
  641.     asm  mov bx,lx;
  642.     asm  mov cx,ly;
  643.         asm  call dword ptr DCREASPRITE;
  644.         asm  mov bvuelta, al
  645.     return bvuelta;}
  646.  
  647. void DibujaSprite(byte hdl,byte pv,word x,word y){
  648.         asm  pusha;
  649.         asm  push ds;
  650.         asm  push es;
  651.     asm  mov al,pv;
  652.     asm  mov ah,hdl
  653.     asm  mov bx,y;
  654.     asm  mov bp,x;
  655.         asm  call dword ptr DDIBUJASPRITE;
  656.         asm  pop es;
  657.         asm  pop ds;
  658.         asm  popa;}
  659.  
  660. void fDibujaSprite(byte hdl,byte pv,word x,word y){
  661.         asm  pusha;
  662.         asm  push ds;
  663.         asm  push es;
  664.     asm  mov al,pv;
  665.     asm  mov ah,hdl
  666.     asm  mov bx,y;
  667.     asm  mov bp,x;
  668.         asm  call dword ptr DFDIBUJASPRITE;
  669.         asm  pop es;
  670.         asm  pop ds;
  671.         asm  popa;}
  672.  
  673. void CargaCEL(char *nombre,byte pv){
  674.     Ssegmento=FP_SEG(nombre);
  675.     Soffset=FP_OFF(nombre);
  676.         asm  push es;
  677.         asm  pusha
  678.     asm  push ds;
  679.     asm  mov ax,Ssegmento;
  680.     asm  mov ds,ax;
  681.     asm  mov dx,Soffset;
  682.     asm  mov al, pv;
  683.         asm  call dword ptr DCARGACEL;
  684.         asm  pop ds;
  685.         asm  popa
  686.         asm  pop es;}
  687.  
  688. byte GetImagen(word x1,word y1,word x2,word y2,byte hdl){
  689.         asm  pusha;
  690.         asm  push es;
  691.         asm  push ds;
  692.     asm  mov al,hdl;
  693.     asm  mov bx,x1;
  694.     asm  mov si,y1;
  695.     asm  mov dx,x2;
  696.     asm  mov di,y2;
  697.         asm  call dword ptr DGETIMAGEN;
  698.         asm  pop ds;
  699.         asm  mov bvuelta,al;
  700.         asm  pop es;
  701.         asm  popa;
  702.         return bvuelta;}
  703.  
  704. byte fGetImagen(word x1,word y1,word x2,word y2,byte hdl){
  705.         asm  pusha;
  706.         asm  push es;
  707.         asm  push ds;
  708.     asm  mov al,hdl;
  709.     asm  mov bx,x1;
  710.     asm  mov si,y1;
  711.     asm  mov dx,x2;
  712.     asm  mov di,y2;
  713.         asm  call dword ptr DFGETIMAGEN;
  714.         asm  mov bvuelta,al;
  715.         asm  pop ds;
  716.         asm  pop es;
  717.         asm  popa;
  718.         return bvuelta;}
  719.  
  720. void DescompPuntos(byte color,word semilla){
  721.         asm  pushad
  722.     asm  mov ax,semilla;
  723.     asm  mov cl,color;
  724.         asm  call dword ptr DDESCOMPPUNTOS;
  725.         asm  popad;}
  726.  
  727. void DescompWorm(byte color,word semilla){
  728.         asm  push es;
  729.         asm  pusha
  730.     asm  mov ax,semilla;
  731.     asm  mov cl,color;
  732.         asm  call dword ptr DDESCOMPWORM;
  733.         asm  popa
  734.         asm  pop es;}
  735.  
  736. byte LeePCX(char *nombre,byte hdl){
  737.     Ssegmento=FP_SEG(nombre);
  738.     Soffset=FP_OFF(nombre);
  739.     asm  push ds;
  740.     asm  mov ax,Ssegmento;
  741.     asm  mov ds,ax;
  742.     asm  mov dx,Soffset;
  743.     asm  mov al,hdl;
  744.         asm  call dword ptr DLEEPCX;
  745.     asm  pop ds;
  746.         asm  mov bvuelta,ah
  747.         return bvuelta;}
  748.  
  749. //  Nuevas en GRAPH 2.0
  750.  
  751. byte LeeBMP(char *nombre,byte hdl){
  752.     Ssegmento=FP_SEG(nombre);
  753.     Soffset=FP_OFF(nombre);
  754.     asm  push ds;
  755.     asm  mov ax,Ssegmento;
  756.     asm  mov ds,ax;
  757.     asm  mov dx,Soffset;
  758.     asm  mov al,hdl;
  759.         asm  call dword ptr DLEEBMP;
  760.     asm  pop ds;
  761.         asm  mov bvuelta,al
  762.         return bvuelta;}
  763.  
  764. void InicGRAPH(word modo, dword flags){
  765.         asm  push ds;
  766.         asm  push es;
  767.         asm  pushad
  768.         asm  mov bx,modo;
  769.         asm  mov eax,flags;
  770.         asm  call dword ptr DINICGRAPH;
  771.         asm  popad
  772.         asm  pop es;
  773.         asm  pop ds;}
  774.  
  775. void EndGRAPH(void){
  776.         asm  push ds;
  777.         asm  push es;
  778.         asm  pushad
  779.         asm  call dword ptr DENDGRAPH;
  780.         asm  popad
  781.         asm  pop es;
  782.         asm  pop ds;}
  783.  
  784. void CambiaTipo(byte new){
  785.         asm  mov al,new;
  786.         asm  call dword ptr DCAMBIATIPO;}
  787.  
  788. byte QueTipo(void){
  789.         asm  call dword ptr DCAMBIATIPO;
  790.         asm  mov bvuelta,al;
  791.         return bvuelta;}
  792.  
  793. void SetCursor(word posx, word posy){
  794.         asm  mov bx,posx;
  795.         asm  mov dx,posy;
  796.         asm  call dword ptr DSETCURSOR;}
  797. /*
  798. void GetCursor(word &posx, word &posy){
  799.         asm  call dword ptr DGETCURSOR;
  800.         asm  mov posx,bx;
  801.         asm  mov posy,dx;}
  802. */
  803. byte CargaFuente(char *nombre,byte lonx,byte lony,byte prime,byte ulti){
  804.     Ssegmento=FP_SEG(nombre);
  805.     Soffset=FP_OFF(nombre);
  806.         asm  push es;
  807.         asm  pusha
  808.     asm  push ds;
  809.     asm  mov ax,Ssegmento;
  810.     asm  mov ds,ax;
  811.     asm  mov dx,Soffset;
  812.         asm  mov bl,lonx;
  813.         asm  mov bh,lony;
  814.         asm  mov ah,prime;
  815.         asm  mov al,ulti;
  816.         asm  call dword ptr DCARGAFUENTE;
  817.     asm  pop ds;
  818.         asm  mov bvuelta,al;
  819.         asm  popa
  820.         asm  pop es;
  821.         return bvuelta;}
  822.  
  823. byte CogeFuenteDOS(void){
  824.         asm  pusha;
  825.         asm  push ds;
  826.         asm  push es;
  827.         asm  call dword ptr DCOGEFUENTEDOS;
  828.         asm  mov bvuelta,al;
  829.         asm  pop es;
  830.         asm  pop ds;
  831.         asm  popa;
  832.         return bvuelta;}
  833.  
  834. void EscLetra(byte hdl, byte letra, byte pv, byte color){
  835.         asm  pusha;
  836.         asm  push ds;
  837.         asm  push es;
  838.         asm  mov al,hdl
  839.         asm  mov ah,letra
  840.         asm  mov bl,pv
  841.         asm  mov bh,color
  842.         asm  call dword ptr DESCLETRA;
  843.         asm  pop es;
  844.         asm  pop ds;
  845.         asm  popa;}
  846.  
  847. void Escribe(byte hdl, char *cadena, byte pv, byte color, byte distx, byte disty){
  848.         Ssegmento=FP_SEG(cadena);
  849.         Soffset=FP_OFF(cadena);
  850.         asm  pusha;
  851.         asm  push ds;
  852.         asm  push es;
  853.         asm  mov ax,Ssegmento
  854.         asm  mov ds,ax
  855.         asm  mov si,Soffset
  856.         asm  mov al,hdl
  857.         asm  mov bl,pv
  858.         asm  mov bh,color
  859.         asm  mov cl,distx
  860.         asm  mov dl,disty
  861.         asm  call dword ptr DESCRIBE;
  862.         asm  pop es;
  863.         asm  pop ds;
  864.         asm  popa;}
  865.  
  866. byte LeeLetra(void){
  867.         asm  call dword ptr DLEELETRA;
  868.         asm  mov bvuelta,al;
  869.         return bvuelta;}
  870.  
  871. byte LeeLetraEcho(byte hdl, byte pv, byte color){
  872.         asm  mov al,hdl
  873.         asm  mov bl,pv
  874.         asm  mov bh,color
  875.         asm  call dword ptr DLEELETRAECHO;
  876.         asm  mov bvuelta,al;
  877.         return bvuelta;}
  878.  
  879. void LeeCadena(byte hdl, char *buffer, byte pv, byte color, byte distx, word longi){
  880.         Ssegmento=FP_SEG(buffer);
  881.         Soffset=FP_OFF(buffer);
  882.         asm  push es
  883.         asm  mov dx,Soffset
  884.         asm  mov al,hdl
  885.         asm  mov bl,pv
  886.         asm  mov bh,color
  887.         asm  mov ah,distx
  888.         asm  mov cx,longi
  889.         asm  push ds
  890.         asm  pop es
  891.         asm  mov ax,Ssegmento
  892.         asm  mov ds,ax
  893.         asm  call dword ptr es:DLEECADENA
  894.         asm  pop es; }
  895.  
  896. void Write(byte hdl, char *cadena, byte pv, byte color, byte distx, byte disty){
  897.         Ssegmento=FP_SEG(cadena);
  898.         Soffset=FP_OFF(cadena);
  899.         asm  pusha;
  900.         asm  push ds;
  901.         asm  push es;
  902.         asm  mov ax,Ssegmento
  903.         asm  mov ds,ax
  904.         asm  mov si,Soffset
  905.         asm  mov al,hdl
  906.         asm  mov bl,pv
  907.         asm  mov bh,color
  908.         asm  mov cl,distx
  909.         asm  mov dl,disty
  910.         asm  call dword ptr DWRITE;
  911.         asm  pop es;
  912.         asm  pop ds;
  913.         asm  popa;}
  914.  
  915. void NuevoArchivo(char *nombre){
  916.     Ssegmento=FP_SEG(nombre);
  917.     Soffset=FP_OFF(nombre);
  918.         asm  push ds;
  919.         asm  push es;
  920.         asm  pusha
  921.         asm  mov ax,Ssegmento;
  922.         asm  mov ds,ax;
  923.         asm  mov si,Soffset;
  924.         asm  call dword ptr DNUEVOARCHIVO;
  925.         asm  popa
  926.         asm  pop es;
  927.         asm  pop ds;}
  928.  
  929. void LeeEntrada(char *buffer, word campo){
  930.         Ssegmento=FP_SEG(buffer);
  931.         Soffset=FP_OFF(buffer);
  932.         asm  push ds;
  933.         asm  push es;
  934.         asm  pusha
  935.         asm  mov ax,Ssegmento;
  936.         asm  mov es,ax;
  937.         asm  mov di,Soffset;
  938.         asm  mov ax,campo;
  939.         asm  call dword ptr DLEEENTRADA;
  940.         asm  popa
  941.         asm  pop es;
  942.         asm  pop ds;}
  943.  
  944. void LeeTrozo(char *buffer, word campo, dword longi, dword inicio){
  945.         Ssegmento=FP_SEG(buffer);
  946.         Soffset=FP_OFF(buffer);
  947.         asm  push ds;
  948.         asm  push es;
  949.         asm  pusha
  950.         asm  mov ax,Ssegmento;
  951.         asm  mov es,ax;
  952.         asm  mov di,Soffset;
  953.         asm  mov ax,campo;
  954.         asm  mov esi,inicio;
  955.         asm  mov ebp,longi;
  956.         asm  call dword ptr DLEETROZO;
  957.         asm  popa
  958.         asm  pop es;
  959.         asm  pop ds;}
  960.  
  961. long LongitudFile(word campo){
  962.         asm  push ds;
  963.         asm  pushad;
  964.         asm  mov ax,campo;
  965.         asm  call dword ptr DLONGITUDFILE;
  966.         asm  mov dvuelta, bp
  967.         asm  shr ebp, 16
  968.         asm  mov wvuelta, bp
  969.         asm  popad;
  970.         asm  pop ds;
  971.         asm  mov dx, wvuelta
  972.         asm  mov ax, dvuelta;}
  973.  
  974. void FlipCopy(byte Opv,byte Dpv){
  975.         asm  push es;
  976.         asm  push ds;
  977.         asm  pusha
  978.         asm  mov al,Opv;
  979.     asm  mov ah,Dpv;
  980.         asm  call dword ptr DFLIPCOPY;
  981.         asm  popa
  982.         asm  pop ds;
  983.         asm  pop es;}
  984.  
  985. void Flip(byte Opv){
  986.         asm  push es;
  987.         asm  push ds;
  988.         asm  pusha
  989.         asm  mov al,Opv;
  990.         asm  call dword ptr DFLIP;
  991.         asm  popa
  992.         asm  pop ds;
  993.         asm  pop es;}
  994.  
  995. word SegmentoFuente(byte Hdl){
  996.     asm  push es;
  997.     asm  mov al,Hdl;
  998.         asm  call dword ptr DSEGMENTOFUENTE;
  999.     asm  mov wvuelta,es;
  1000.         asm  pop es;
  1001.     return wvuelta;}
  1002.  
  1003. void DoblaLineas(void){
  1004.         asm  call dword ptr DDOBLALINEAS;}
  1005.  
  1006. void SetStart(word direc){
  1007.         asm  mov bx,direc;
  1008.     asm  call dword ptr DSETSTART;}
  1009.  
  1010. void SetVSPixels(byte lineas){
  1011.         asm  mov ah,lineas;
  1012.         asm  call dword ptr DSETVSPIXELS;}
  1013.  
  1014. word PideXMS(word memo){
  1015.         asm  pusha
  1016.         asm  mov dx,memo;
  1017.         asm  call dword ptr DPIDEXMS;
  1018.         asm  mov wvuelta,dx
  1019.         asm  popa
  1020.         return wvuelta;}
  1021.  
  1022. void LiberaXMS(word memo){
  1023.         asm  pusha
  1024.         asm  mov dx,memo;
  1025.         asm  call dword ptr DLIBERAXMS;
  1026.         asm  popa;}
  1027.  
  1028. long GetAddress(word hdl){
  1029.         asm  mov dx,hdl;
  1030.         asm  call dword ptr DGETADDRESS;
  1031.         asm  mov ax, dx
  1032.         asm  shr edx, 16;}
  1033.  
  1034. word MaximaXMS(void){
  1035.         asm  call dword ptr DMAXIMAXMS;
  1036.         asm  mov wvuelta,dx;
  1037.         return wvuelta;}
  1038.  
  1039. word GuardaFlat(byte hdl, byte tipo){
  1040.         asm  push ds;
  1041.         asm  push gs;
  1042.         asm  push es;
  1043.         asm  pusha
  1044.         asm  mov al,hdl;
  1045.         asm  mov ah,tipo;
  1046.         asm  call dword ptr DGUARDAFLAT;
  1047.         asm  mov wvuelta,dx;
  1048.         asm  popa
  1049.         asm  pop es;
  1050.         asm  pop gs;
  1051.         asm  pop ds;
  1052.         return wvuelta;}
  1053.  
  1054. void CargaFlat(byte hdl, byte tipo, word hdlxms){
  1055.         asm  push ds;
  1056.         asm  push gs;
  1057.         asm  pusha
  1058.         asm  mov al,hdl;
  1059.         asm  mov ah,tipo;
  1060.         asm  mov dx,hdlxms;
  1061.         asm  call dword ptr DCARGAFLAT;
  1062.         asm  popa
  1063.         asm  pop gs;
  1064.         asm  pop ds;}
  1065.  
  1066. byte CargaBloque(char *nombre){
  1067.     Ssegmento=FP_SEG(nombre);
  1068.     Soffset=FP_OFF(nombre);
  1069.         asm  push es;
  1070.         asm  pusha
  1071.     asm  push ds;
  1072.     asm  mov ax,Ssegmento;
  1073.     asm  mov ds,ax;
  1074.     asm  mov dx,Soffset;
  1075.         asm  call dword ptr DCARGABLOQUE;
  1076.     asm  pop ds;
  1077.         asm  mov bvuelta,al;
  1078.         asm  popa
  1079.         asm  pop es;
  1080.         return bvuelta;}
  1081.  
  1082. byte CargaMapa(char *nombre){
  1083.     Ssegmento=FP_SEG(nombre);
  1084.     Soffset=FP_OFF(nombre);
  1085.         asm  push es;
  1086.         asm  pusha
  1087.     asm  push ds;
  1088.     asm  mov ax,Ssegmento;
  1089.     asm  mov ds,ax;
  1090.     asm  mov dx,Soffset;
  1091.         asm  call dword ptr DCARGAMAPA;
  1092.     asm  pop ds;
  1093.         asm  mov bvuelta,al;
  1094.         asm  popa
  1095.         asm  pop es;
  1096.         return bvuelta;}
  1097.  
  1098. void DestBloque(byte hdl){
  1099.         asm  push es;
  1100.         asm  pusha
  1101.         asm  mov al,hdl;
  1102.         asm  call dword ptr DDESTBLOQUE;
  1103.         asm  popa
  1104.         asm  pop es;}
  1105.  
  1106. void DestMapa(byte hdl){
  1107.         asm  push es;
  1108.         asm  pusha
  1109.         asm  mov al,hdl;
  1110.         asm  call dword ptr DDESTMAPA;
  1111.         asm  popa
  1112.         asm  pop es;}
  1113.  
  1114. void DibujaMapa(byte pv, byte hmapa, byte hblk, dword posx, dword posy){
  1115.         asm  push es;
  1116.         asm  push ds;
  1117.         asm  push gs;
  1118.         asm  push fs;
  1119.         asm  pusha;
  1120.         asm  mov al,pv;
  1121.         asm  mov bl,hmapa;
  1122.         asm  mov bh,hblk;
  1123.         asm  mov ecx,posx;
  1124.         asm  mov edx,posy;
  1125.         asm  call dword ptr DDIBUJAMAPA;
  1126.         asm  popa;
  1127.         asm  pop fs;
  1128.         asm  pop gs;
  1129.         asm  pop ds;
  1130.         asm  pop es;}
  1131.  
  1132. word PosMapa(byte hdl, word posx, word posy){
  1133.         asm  push ds;
  1134.         asm  pusha;
  1135.         asm  mov al,hdl;
  1136.         asm  mov cx,posx;
  1137.         asm  mov dx,posy;
  1138.         asm  call dword ptr DPOSMAPA;
  1139.         asm  mov wvuelta,ax;
  1140.         asm  popa;
  1141.         asm  pop ds;
  1142.         return wvuelta;}
  1143.  
  1144. void InsertaDirBloque(word seg, byte longx, byte longy, word numero){
  1145.     asm  push es;
  1146.     asm  mov ax,seg;
  1147.     asm  mov es,ax;
  1148.         asm  mov cl,longy;
  1149.         asm  mov dh,longx;
  1150.         asm  mov dx,numero;
  1151.         asm  call dword ptr DINSERTADIRBLOQUE;
  1152.     asm  pop es;}
  1153.  
  1154. void InsertaDirMapa(word seg, word longx, word longy){
  1155.     asm  push es;
  1156.     asm  mov ax,seg;
  1157.     asm  mov es,ax;
  1158.         asm  mov cx,longy;
  1159.         asm  mov dx,longx;
  1160.         asm  call dword ptr DINSERTADIRMAPA;
  1161.     asm  pop es;}
  1162.  
  1163. void ResetGRAPH(word modo, dword flags){
  1164.         asm  push es;
  1165.         asm  push ds;
  1166.         asm  pushad
  1167.         asm  mov bx,modo;
  1168.         asm  mov eax,flags;
  1169.         asm  call dword ptr DRESETGRAPH;
  1170.         asm  popad
  1171.         asm  pop ds;
  1172.         asm  pop es;}
  1173.  
  1174. word SegmentoBloque(byte Hdl){
  1175.     asm  push es;
  1176.     asm  mov al,Hdl;
  1177.         asm  call dword ptr DSEGMENTOBLOQUE;
  1178.     asm  mov wvuelta,es;
  1179.         asm  pop es;
  1180.     return wvuelta;}
  1181.  
  1182. word SegmentoMapa(byte Hdl){
  1183.     asm  push es;
  1184.     asm  mov al,Hdl;
  1185.         asm  call dword ptr DSEGMENTOMAPA;
  1186.     asm  mov wvuelta,es;
  1187.         asm  pop es;
  1188.     return wvuelta;}
  1189.  
  1190. void PlayFLI(char *nombre, word pausa){
  1191.     Ssegmento=FP_SEG(nombre);
  1192.     Soffset=FP_OFF(nombre);
  1193.         asm  push es;
  1194.         asm  push ds;
  1195.         asm  pusha;
  1196.         asm  mov ax,Ssegmento;
  1197.         asm  mov ds,ax;
  1198.         asm  mov dx,Soffset;
  1199.         asm  mov ax,pausa;
  1200.         asm  call dword ptr DPLAYFLI;
  1201.         asm  popa;
  1202.         asm  pop ds;
  1203.         asm  pop es;}
  1204.  
  1205. byte CreaMapa(word longx, word longy){
  1206.         asm  pusha
  1207.         asm  mov ax,longx;
  1208.         asm  mov cx,longy;
  1209.         asm  call dword ptr DCREAMAPA;
  1210.         asm  mov bvuelta,al;
  1211.         asm  popa
  1212.         return bvuelta;}
  1213.  
  1214. byte CreaBloque(byte longx, byte longy, word numero){
  1215.         asm  pusha
  1216.         asm  mov al,longx;
  1217.         asm  mov ah,longy;
  1218.         asm  mov cx,numero;
  1219.         asm  call dword ptr DCREABLOQUE;
  1220.         asm  mov bvuelta,al;
  1221.         asm  popa
  1222.         return bvuelta;}
  1223.  
  1224. void DestFuente(byte hdl){
  1225.         asm  push es;
  1226.         asm  pusha
  1227.         asm  mov al,hdl;
  1228.         asm  call dword ptr DDESTFUENTE;
  1229.         asm  popa
  1230.         asm  pop es;}
  1231.  
  1232. void InsertaDirFuente(word seg, byte longx, byte longy, byte prim, byte ult){
  1233.     asm  push es;
  1234.     asm  mov ax,seg;
  1235.     asm  mov es,ax;
  1236.         asm  mov cl,longy;
  1237.         asm  mov ch,longx;
  1238.         asm  mov al,prim;
  1239.         asm  mov ah,ult;
  1240.         asm  call dword ptr DINSERTADIRFUENTE;
  1241.     asm  pop es;}
  1242.  
  1243.  
  1244.